package com.quanquan.management.service;

import com.alibaba.fastjson.JSONObject;
import com.quanquan.management.dto.AdsenceDTO;
import com.quanquan.management.request.AdsenceRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import utils.Request;

import java.util.List;

/**
 * @ClassName:AdsenceService
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/5/23 10:30
 * @Version 1.0
 */
@Service
public class AdsenceService {

    @Value("${module-url.storeUrl}")
    private String storeUrl;

    public List<AdsenceDTO> list(){
        AdsenceRequest adsenceRequest = new AdsenceRequest();
        String postJson = Request.postJson(storeUrl + "adsence/query_list", adsenceRequest);
        JSONObject jsonObject = JSONObject.parseObject(postJson);
        Integer resCode = jsonObject.getInteger("resCode");
        List<AdsenceDTO> pageDTO = null;
        if (0 == resCode) {
            return jsonObject.getJSONArray("data").toJavaList(AdsenceDTO.class);
        }
        return pageDTO;
    }



}
